package com.athena.framework.init;

import com.athena.framework.annotation.Annotation;
import com.athena.framework.authority.Security;
import com.athena.framework.config.HttpContentType;
import com.athena.framework.exception.FileException;
import com.athena.framework.proxy.ProxyInit;
import com.athena.framework.url.websocket.WebSocket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

/**
 * 初始化和启动framework
 */
public class FrameworkStart {

    private final static Logger logger = LoggerFactory.getLogger(FrameworkStart.class);

    /**
     * 初始化framework，解析各个需要被管理的注解
     */
    public void init() {
        //初始化HttpContentType
        try {
            HttpContentType.init();
        } catch (IOException e) {
            String msg = "解析ContetType文件失败！";
            throw new FileException(msg);
        }

        //解析注解
        new Annotation().parsingAnnotation();

        //设置aop代理类
        new ProxyInit().parsing();

        //初始化设置权限实现类
        Security.initSetAuthorityClass();

        //启动websocket服务
        new WebSocket().start();

        if (logger.isInfoEnabled()) {
            logger.info("framework启动完成！！！");
        }
    }

}
